<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文章</title>
    <style>
        html body{
            width: 100%;
            height: 100%;
            margin: 0px;
            background-color: lightblue;
            text-align: center;
        }
        #articleDiv{
            display:inline-block;
            width: 80%;
            text-align: left;
            margin-top: 50px;
        }
    </style>
</head>
<body>
    <div id="articleDiv">

    </div>

    <!-- 导入jquery -->
    <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.6.0.js"></script>
    <script type="text/javascript">
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) {
                return unescape(r[2]); 
            }
            return null;
        }
        $(document).ready(function () {
            var articleId = getUrlParam('id');

            var requestData = new Object();
            requestData.articleId = articleId;
            
            var url = "http://127.0.0.1:80";
            url += "/view";
            $.post(url,JSON.stringify(requestData),function(response){
                var result = JSON.parse(response);
                if(result.result == "success"){
                    $('#articleDiv').html(result.content);
                    return;
                }

                alert("该文章不存在，请联系管理员！");
            });
        });
    </script>
</body>
</html>